/*
 * @Author: Seven
 * @Date: 2021-11-28 21:05:31
 * @LastEditors: Seven
 * @LastEditTime: 2021-11-28 21:10:38
 * @FilePath: \def-standard\src\store\modules\global.js
 * @Description: 存储全局（配置）变量
 */

const globalState = {
    state: () => ({
        //控制是否显示侧边栏
        showSider: false,
        //控制是否显示切换语言弹窗
        languageModalVisible: false,
        //激活用户弹窗
        activeModalVisible: false, 
        // 当前交易个数
        requestNum: 0,
        //异步等待时loading
        loading:false
    }),
    mutations: {
        switch_sider(state, value) {
            state.showSider = value
        },
        switch_language_modal(state, value) {
            state.languageModalVisible = value
        },
        switch_active_modal(state, value){
            state.activeModalVisible = value
        },
        add_request_num(state) {
            state.requestNum++;
            state.loading = true;
        },
        reduce_request_num(state) {
            if (state.requestNum > 0){
                state.requestNum--;
                state.loading = false;
            } 
        }
    }
}

export default globalState
